package collection;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionOperDemo {

    public static void main(String[] args) {
        Collection c1=new ArrayList();
        c1.add("a");
        c1.add("b");
        c1.add("c");
        c1.add("d");
        c1.add("e");
        System.out.println(c1);
        Collection c2=new ArrayList();
        c2.add("f");
        c2.add("g");
        c2.add("h");
        c2.add("i");
        c2.add("j");
        System.out.println(c2);
        c1.addAll(c2);
        System.out.println(c1);
        System.out.println(c2);
        Collection c3=new ArrayList();
        c3.add("a");
        c3.add("n");
        c3.add("m");
        c3.add("d");
        c3.add("h");
        System.out.println(c3);
        boolean contains=c1.contains(c3);
        System.out.println("c1是否包含c3"+contains);

        c1.removeAll(c3);
        System.out.println(c1);
        System.out.println(c3);
        /*
        Collection c1=new ArrayList();
        c1.add("java");
        c1.add("c++");
        c1.add(".net");
        System.out.println("c1:"+c1);
        Collection c2=new ArrayList();
        c2.add("android");
        c2.add("ios");
        c2.add("java");
        System.out.println("c2:"+c2);
        c1.addAll(c2);
        System.out.println("c1:"+c1);//c1:[java, c++, .net, android, ios, java]
        System.out.println("c2:"+c2);//c2:[android, ios, java]


        Collection c3=new ArrayList();
        c3.add("c++");
        c3.add("android");
        c3.add("php");
        System.out.println("c3:"+c3);
        boolean contains=c1.contains(c3);
        System.out.println("是否包含"+contains);



        c1.retainAll(c3);
        System.out.println("c1"+c1);//c1[c++, android]
        System.out.println("c3"+c3);//c3[c++, android, php]


        //删交集
        c1.removeAll(c3);
        System.out.println("c1"+c1);//c1[java, .net, ios, java]
        System.out.println("c3"+c3);//c3[c++, android, php]

     */
    }
}
